package org.naxx.security.util;

import java.io.InputStream;

public final class ClasspathUtil {

	public static InputStream getClasspathResource(Object instance, 
			String simpleFileName) {
		String classPathLocation = instance.getClass().getPackage()
			.getName().replace('.', '/');
		return Thread.currentThread().getContextClassLoader()
			.getResourceAsStream(classPathLocation + '/' + simpleFileName);
	}
	
	public static InputStream getResourceFromClasspath(String resourceName) {
		return Thread.currentThread().getContextClassLoader()
			.getResourceAsStream(resourceName);
	}
	
	private ClasspathUtil() {
		throw new IllegalStateException("Can not instantiate class '" 
				+ ClasspathUtil.class.getCanonicalName() + "'.");
	}
}
